<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<title>Novo Processo</title>
</h:head>
<ui:composition template="templatePrincipal.xhtml">
	<ui:define name="header">
		<ui:include src="header.xhtml" />
	</ui:define>
	<ui:define name="centro">
		<h:body>
			<p:growl id="messages" showDetail="true" life="1000" />
			<h:form id="form1">
				<p:panel header="Dados do cliente do processo">
					<p:panelGrid>
						<p:row>
							<p:column>
								<p:outputLabel for="pesqproponente" value="Proponente : " />
								<p:autoComplete id="pesqproponente"
									value="#{processoController.processo.cliente}"
									completeMethod="#{processoController.completeCliente}"
									var="cliente" itemLabel="#{cliente.proponente}"
									itemValue="#{cliente}" converter="clienteConverter">
									<p:ajax event="blur" update="selecionaImovel" />
								</p:autoComplete>
							</p:column>
							<p:column>
								<p:outputLabel for="pesqvendedor" value="Vendedor : " />
								<p:autoComplete id="pesqvendedor"
									value="#{processoController.processo.vendedor}"
									completeMethod="#{processoController.completeVendedor}"
									var="vendedor" itemLabel="#{vendedor.nome}"
									itemValue="#{vendedor}" converter="vendedorConverter" />
							</p:column>
							<p:column>
								<p:outputLabel for="pesqcorretor" value="Corretor : " />
								<p:autoComplete id="pesqcorretor"
									value="#{processoController.processo.corretor}"
									completeMethod="#{processoController.completeCorretor}"
									var="corretor" itemLabel="#{corretor.nome}"
									itemValue="#{corretor}" converter="corretorConverter" />
							</p:column>
							<p:column>
								<p:outputLabel for="primeiroimovel" value="Primeiro Imovel : " />
								<p:selectBooleanCheckbox id="primeiroimovel"
									value="#{processoController.processo.primeiroImovel}" />
							</p:column>

							<p:column>
								<h:outputText value="Imovel : " />
								<p:selectOneMenu value="#{processoController.selectedImovel}"
									converter="imovelConverter" id="selecionaImovel"
									process="@this">
									<f:selectItems
										value="#{processoController.processo.cliente.imoveis}"
										var="imovel" itemLabel="#{imovel.matricula}"
										itemValue="#{imovel}" />
								</p:selectOneMenu>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:panel>
				<p:panel header="CheckList do processo">
					<p:outputLabel for="tituloList" value="CheckList :" />
					<p:selectOneMenu id="tituloList"
						value="#{processoController.processo.pchkheader.titulo}" converter="stringConverter">
						<f:selectItems value="#{processoController.listaTitulo}"
							var="titulo" itemLabel="#{titulo}"
							itemValue="#{titulo}" />
						<!-- 
							itemValue="#{titulo}" />
					 		-->
					</p:selectOneMenu>
					<!-- 
					<p:outputPanel id="criaBntOutp">
						<p:commandButton
							rendered="#{processoController.criaProcessoRendered}"
							id="criaprocessobnt" value="Cria Processo"
							actionListener="#{processoController.createProcesso}"
							update="checkListoutp,criaBntOutp, pDadosProcesso,:messages" />
					</p:outputPanel>
					 -->
				</p:panel>
				<p:outputPanel id="pDadosProcesso">
					<p:panel header="Dados do Processo">
						<!-- 
						rendered="#{processoController.checkListRendered}">
						 -->
						<p:panelGrid>
							<f:facet name="header">
								<p:row>
									<p:column> Operação </p:column>
									<p:column> Tipo </p:column>
									<p:column> Modalidade 1 </p:column>
									<p:column> Modalidade 2 </p:column>
								</p:row>
							</f:facet>
							<p:row>
								<p:column>
									<p:selectOneMenu id="operacaoList"
										value="#{processoController.processo.pchkheader.operacao}"
										converter="stringConverter">
										<f:selectItems value="#{processoController.listaOperacao}"
											var="operacao" itemLabel="#{operacao}"
											itemValue="#{operacao}" />
										<!-- 
											itemValue="#{operacao}" />
											 -->
									</p:selectOneMenu>
								</p:column>
								<p:column>
									<p:selectOneMenu id="tipoList"
										value="#{processoController.processo.pchkheader.tipo}" converter="stringConverter">
										<f:selectItems value="#{processoController.listaTipo}"
											var="tipo" itemLabel="#{tipo}"
											itemValue="#{tipo}" />
										<!-- 
											itemValue="#{tipo}" />
											 -->
									</p:selectOneMenu>
								</p:column>
								<p:column>
									<p:selectOneMenu id="modal1List"
										value="#{processoController.processo.pchkheader.modalidade1}"
										converter="stringConverter">
										<f:selectItems value="#{processoController.listaModal1}"
											var="modal1" itemLabel="#{modal1}"
											itemValue="#{modal1}" />
										<!-- 
											itemValue="#{modal1}" />
											 -->
									</p:selectOneMenu>
								</p:column>
								<p:column>
									<p:selectOneMenu id="modal2List"
										value="#{processoController.processo.pchkheader.modalidade2}"
										converter="stringConverter">
										<f:selectItems value="#{processoController.listaModal2}"
											var="modal2" itemLabel="#{modal2}"
											itemValue="#{modal2}" />
										<!-- 
											itemValue="#{modal2}" />
											 -->
									</p:selectOneMenu>
								</p:column>



							</p:row>
						</p:panelGrid>

						<p:outputPanel id="criaBntOutp">
							<p:commandButton
								rendered="#{processoController.criaProcessoRendered}"
								id="criaprocessobnt" value="Cria Processo"
								actionListener="#{processoController.createProcesso}"
								update="checkListoutp,criaBntOutp,:messages" />
						</p:outputPanel>


						<!-- 
						<p:outputLabel for="operacaoList" value="Operacao : " />
						<p:selectOneMenu id="operacaoList"
							value="#{processoController.operacao}"
							converter="stringConverter">
							<f:selectItems value="#{processoController.listaOperacao}"
								var="operacao" itemLabel="#{operacao}" itemValue="#{operacao}" />
						</p:selectOneMenu>

						<p:outputLabel for="tipoList" value="Tipo : " />
						<p:selectOneMenu id="tipoList" value="#{processoController.tipo}"
							converter="stringConverter">
							<f:selectItems value="#{processoController.listaTipo}" var="tipo"
								itemLabel="#{tipo}" itemValue="#{tipo}" />
						</p:selectOneMenu>

						<p:outputLabel for="modal1List" value="Modalidade 1 : " />
						<p:selectOneMenu id="modal1List"
							value="#{processoController.modalidade1}"
							converter="stringConverter">
							<f:selectItems value="#{processoController.listaModal1}"
								var="modal1" itemLabel="#{modal1}" itemValue="#{modal1}" />
						</p:selectOneMenu>

						<p:outputLabel for="modal2List" value="Modalidade 2 : " />
						<p:selectOneMenu id="modal2List"
							value="#{processoController.modalidade2}"
							converter="stringConverter">
							<f:selectItems value="#{processoController.listaModal2}"
								var="modal2" itemLabel="#{modal2}" itemValue="#{modal2}" />
						</p:selectOneMenu>
						 -->

						<!-- 
					<p:outputPanel id="criaBntOutp">
						<p:commandButton
							rendered="#{processoController.criaProcessoRendered}"
							id="criaprocessobnt" value="Cria Processo"
							actionListener="#{processoController.createProcesso}"
							update="checkListoutp,criaBntOutp,:messages" />
					</p:outputPanel>
					 -->
					</p:panel>
				</p:outputPanel>

				<p:outputPanel id="checkListoutp">
					<p:tabView id="tabview1"
						rendered="#{processoController.checkListRendered}" dynamic="true"
						cache="false">
						<p:tab id="tabchk" title="Check List">
							<p:panel
								header="#{processoController.processo.pchkheader.titulo}"
								id="dataTable">
								<p:accordionPanel value="#{processoController.chklistPerGroup}"
									var="chkitem">
									<p:tab title="#{chkitem.group}">
										<h:panelGrid>
											<p:dataTable id="dataTablechk" var="chkline"
												value="#{chkitem.checkListItems}"
												selection="#{processoController.selectedChkLine}"
												selectionMode="single" rowKey="#{chkline.processChk_id}">
												<p:column>
													<f:facet name="header">
														<h:outputText value="Descrição" />
													</f:facet>
													<h:outputText value="#{chkline.descricao}" />
												</p:column>
												<p:column>
													<f:facet name="header">
														<h:outputText value="Verificado" />
													</f:facet>
													<p:selectBooleanCheckbox value="#{chkline.checked}">
														<!-- 
														<p:ajax event="change"
															listener="#{processoController.changeValue}"
															update="dataTablechk" />
													 	-->
													</p:selectBooleanCheckbox>
												</p:column>
												<p:column>
													<f:facet name="header">
														<h:outputText value="Opicional" />
													</f:facet>

													<p:selectBooleanCheckbox value="#{chkline.opcional}">
														<!-- 
														<p:ajax event="change"
															listener="#{processoController.changeValue}"
															update="dataTablechk" />
															 -->
													</p:selectBooleanCheckbox>
												</p:column>
												<p:column>
													<f:facet name="header">
														<h:outputText value="Comentário" />
													</f:facet>
													<p:inputText value="#{chkline.comentario}" />
												</p:column>
											</p:dataTable>
										</h:panelGrid>
									</p:tab>
								</p:accordionPanel>
							</p:panel>

							<p:panel rendered="#{processoController.checkListRendered}"
								header="Observações">
								<p:inputTextarea rows="6" cols="33"
									value='#{processoController.processo.observacoes}' />

								<p:commandButton id="salvaprocessobnt" value="Salvar Processo"
									actionListener="#{processoController.salvarProcesso}"
									update="dataTable,:messages" />
							</p:panel>

						</p:tab>
						<p:tab id="tabcustoteste" title="Custo do Processo">
							<p:panelGrid columns="2" style="width:100%">
								<p:panel header="Base de Calculo" id="panelbase">
									<p:panelGrid columns="2">
										<h:outputLabel for="itbi" value="Taxa de ITBI : " />
										<p:inputText id="itbi"
											value="#{processoController.processo.custo.paramibti}"
											label="itbi" />

										<h:outputLabel for="matricula" value="Valor da matricula : " />
										<p:inputText id="matricula"
											value="#{processoController.processo.custo.paramvmatricula}"
											label="matricula" />

										<h:outputLabel for="ccfgts" value="Taxa de CCFGTS : " />
										<p:inputText id="ccfgts"
											value="#{processoController.processo.custo.paramtxccfgts}"
											label="ccfgts" />

										<h:outputLabel for="ccsbte" value="Taxa de CCSBTE : " />
										<p:inputText id="ccsbte"
											value="#{processoController.processo.custo.paramtxccsbte}"
											label="ccsbte" />

										<h:outputLabel for="seguro" value="Valor do P. Seguro : " />
										<p:inputText id="seguro"
											value="#{processoController.processo.custo.parampremioseguro}"
											label="seguro" />

										<h:outputLabel for="pesqcad"
											value="Valor da Pesquisa Cadastral : " />
										<p:inputText id="pesqcad"
											value="#{processoController.processo.custo.parampesqcadastral}"
											label="pesqcad" />

										<h:outputLabel for="despachante"
											value="Valor do Despachante : " />
										<p:inputText id="despachante"
											value="#{processoController.processo.custo.paramdesp}"
											label="despachante" />

									</p:panelGrid>

								</p:panel>

								<p:panel header="Custo Detalhado" id="paneldetalhado">

									<p:panelGrid columns="2">
										<h:outputLabel for="cnotas" value="Cartório de notas : " />
										<p:inputText id="cnotas"
											value="#{processoController.processo.custo.custocnotas}"
											label="cnotas" />


										<h:outputLabel for="cri"
											value="Cartório de registro de imóveis : " />
										<p:inputText id="cri"
											value="#{processoController.processo.custo.custocri}"
											label="cri" />

										<h:outputLabel for="custoitbi" value="Custo ITBI : " />
										<p:inputText id="custoitbi"
											value="#{processoController.processo.custo.cusoibti}"
											label="custoitbi" />

										<h:outputLabel for="custocaixa" value="Custo Caixa : " />
										<p:inputText id="custocaixa"
											value="#{processoController.processo.custo.custocaixa}"
											label="custocaixa" />

										<h:outputLabel for="custodesp" value="Custo do Despachante : " />
										<p:inputText id="custodesp"
											value="#{processoController.processo.custo.custodesp}"
											label="custodesp" />


										<h:outputLabel for="custototal" value="Custo Total : " />
										<p:inputText id="custototal"
											value="#{processoController.processo.custo.custototal}"
											label="custototal" />

									</p:panelGrid>

								</p:panel>

							</p:panelGrid>

							<p:commandButton id="calculabnt" value="Calula Custo"
								actionListener="#{processoController.calculaCusto}"
								update="paneldetalhado,:messages" />

						</p:tab>

					</p:tabView>
				</p:outputPanel>
			</h:form>
		</h:body>
	</ui:define>
</ui:composition>
</html>